<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickshadereffectsource.cpp -->
  <title>ShaderEffectSource QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >ShaderEffectSource QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">ShaderEffectSource QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$ShaderEffectSource-brief -->
<p>Renders a <a href="qtquick-index.html">Qt Quick 模块</a> item into a texture and displays it. <a href="#details">更多...</a></p>
<!-- @@@ShaderEffectSource -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.0</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-item.html">Item</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-shadereffectsource-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#format-prop">format</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#hideSource-prop">hideSource</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#live-prop">live</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#mipmap-prop">mipmap</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#recursive-prop">recursive</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#samples-prop">samples</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a></b></b> : Item</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#sourceRect-prop">sourceRect</a></b></b> : rect</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#textureMirroring-prop">textureMirroring</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#textureSize-prop">textureSize</a></b></b> : size</li>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#wrapMode-prop">wrapMode</a></b></b> : enumeration</li>
</ul>
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-shadereffectsource.html#scheduleUpdate-method">scheduleUpdate</a></b></b>()</li>
</ul>
<!-- $$$ShaderEffectSource-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p>The <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> type renders <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> into a texture and displays it in the scene. <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> is drawn into the texture as though it was a fully opaque root item. Thus <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> itself can be invisible, but still appear in the texture.</p>
<p><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> can be used as:</p>
<ul>
<li>a texture source in a <a href="qml-qtquick-shadereffect.html">ShaderEffect</a>. This allows you to apply custom shader effects to any <a href="qtquick-index.html">Qt Quick 模块</a> item.</li>
<li>a cache for a complex item. The complex item can be rendered once into the texture, which can then be animated freely without the need to render the complex item again every frame.</li>
<li>an opacity layer. <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> allows you to apply an opacity to items as a group rather than each item individually.</li>
</ul>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/declarative-shadereffectsource.png" alt="" /></p></td><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
      <span class="name">width</span>: <span class="number">200</span>
      <span class="name">height</span>: <span class="number">100</span>
      <span class="name">gradient</span>: <span class="name">Gradient</span> {
          <span class="type"><a href="qml-qtquick-gradientstop.html">GradientStop</a></span> { <span class="name">position</span>: <span class="number">0</span>; <span class="name">color</span>: <span class="string">&quot;white&quot;</span> }
          <span class="type"><a href="qml-qtquick-gradientstop.html">GradientStop</a></span> { <span class="name">position</span>: <span class="number">1</span>; <span class="name">color</span>: <span class="string">&quot;black&quot;</span> }
      }
      <span class="type"><a href="qml-qtquick-row.html">Row</a></span> {
          <span class="name">opacity</span>: <span class="number">0.5</span>
          <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
              <span class="name">id</span>: <span class="name">foo</span>
              <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
              <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">x</span>: <span class="number">5</span>; <span class="name">y</span>: <span class="number">5</span>; <span class="name">width</span>: <span class="number">60</span>; <span class="name">height</span>: <span class="number">60</span>; <span class="name">color</span>: <span class="string">&quot;red&quot;</span> }
              <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">x</span>: <span class="number">20</span>; <span class="name">y</span>: <span class="number">20</span>; <span class="name">width</span>: <span class="number">60</span>; <span class="name">height</span>: <span class="number">60</span>; <span class="name">color</span>: <span class="string">&quot;orange&quot;</span> }
              <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">x</span>: <span class="number">35</span>; <span class="name">y</span>: <span class="number">35</span>; <span class="name">width</span>: <span class="number">60</span>; <span class="name">height</span>: <span class="number">60</span>; <span class="name">color</span>: <span class="string">&quot;yellow&quot;</span> }
          }
          <span class="type"><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a></span> {
              <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
              <span class="name">sourceItem</span>: <span class="name">foo</span>
          }
      }
  }

</pre>
</td></tr>
</table></div>
<p>The <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> type does not redirect any mouse or keyboard input to <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a>. If you hide the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> by setting <a href="qml-qtquick-item.html#visible-prop">visible</a> to false or <a href="qml-qtquick-item.html#opacity-prop">opacity</a> to zero, it will no longer react to input. In cases where the <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> is meant to replace the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a>, you typically want to hide the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> while still handling input. For this, you can use the <a href="qml-qtquick-shadereffectsource.html#hideSource-prop">hideSource</a> property.</p>
<p><b>Note: </b>If <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> is a <a href="qml-qtquick-rectangle.html">Rectangle</a> with border, by default half the border width falls outside the texture. To get the whole border, you can extend the <a href="qml-qtquick-shadereffectsource.html#sourceRect-prop">sourceRect</a>.</p><p><b>Note: </b>The <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> relies on FBO multisampling support to antialias edges. If the underlying hardware does not support this, which is the case for most embedded graphics chips, edges rendered inside a <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> will not be antialiased. One way to remedy this is to double the size of the effect source and render it with <code>smooth: true</code> (this is the default value of smooth). This will be equivalent to 4x multisampling, at the cost of lower performance and higher memory use.</p><p><b>Warning:</b> In most cases, using a <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> will decrease performance, and in all cases, it will increase video memory usage. Rendering through a <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> might also lead to lower quality since some OpenGL implementations support multisampled backbuffer, but not multisampled framebuffer objects.</p>
<!-- @@@ShaderEffectSource -->
<h2>属性文档</h2>
<!-- $$$format -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="format-prop">
<td class="tblQmlPropNode"><p>
<a name="format-prop"></a><span class="name">format</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property defines the internal OpenGL format of the texture. Modifying this property makes most sense when the item is used as a source texture of a <a href="qml-qtquick-shadereffect.html">ShaderEffect</a>. Depending on the OpenGL implementation, this property might allow you to save some texture memory.</p>
<ul>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.Alpha - GL_ALPHA</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.RGB - GL_RGB</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.RGBA - GL_RGBA</li>
</ul>
<p><b>Note: </b>Some OpenGL implementations do not support the GL_ALPHA format.</p></div></div><!-- @@@format -->
<br/>
<!-- $$$hideSource -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="hideSource-prop">
<td class="tblQmlPropNode"><p>
<a name="hideSource-prop"></a><span class="name">hideSource</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this property is true, the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> is hidden, though it will still be rendered into the texture. As opposed to hiding the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> by setting <a href="qml-qtquick-item.html#visible-prop">visible</a> to false, setting this property to true will not prevent mouse or keyboard input from reaching <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a>. The property is useful when the <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> is anchored on top of, and meant to replace the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a>.</p>
</div></div><!-- @@@hideSource -->
<br/>
<!-- $$$live -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="live-prop">
<td class="tblQmlPropNode"><p>
<a name="live-prop"></a><span class="name">live</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this property is true, the texture is updated whenever the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> updates. Otherwise, it will be a frozen image, even if <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> is assigned a new item. The property is true by default.</p>
</div></div><!-- @@@live -->
<br/>
<!-- $$$mipmap -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="mipmap-prop">
<td class="tblQmlPropNode"><p>
<a name="mipmap-prop"></a><span class="name">mipmap</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this property is true, mipmaps are generated for the texture.</p>
<p><b>Note: </b>Some OpenGL ES 2 implementations do not support mipmapping of non-power-of-two textures.</p></div></div><!-- @@@mipmap -->
<br/>
<!-- $$$recursive -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="recursive-prop">
<td class="tblQmlPropNode"><p>
<a name="recursive-prop"></a><span class="name">recursive</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Set this property to true if the <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> has a dependency on itself. ShaderEffectSources form a dependency chain, where one <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> can be part of the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> of another. If there is a loop in this chain, a <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> could end up trying to render into the same texture it is using as source, which is not allowed by OpenGL. When this property is set to true, an extra texture is allocated so that <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> can keep a copy of the texture from the previous frame. It can then render into one texture and use the texture from the previous frame as source.</p>
<p>Setting both this property and <a href="qml-qtquick-shadereffectsource.html#live-prop">live</a> to true will cause the scene graph to render continuously. Since the <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> depends on itself, updating it means that it immediately becomes dirty again.</p>
</div></div><!-- @@@recursive -->
<br/>
<!-- $$$samples -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="samples-prop">
<td class="tblQmlPropNode"><p>
<a name="samples-prop"></a><span class="name">samples</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property allows requesting multisampled rendering.</p>
<p>By default multisampling is enabled whenever multisampling is enabled for the entire window, assuming the scenegraph renderer in use and the underlying graphics API supports this.</p>
<p>By setting the value to 2, 4, etc. multisampled rendering can be requested for a part of the scene without enabling multisampling for the entire scene. This way multisampling is applied only to a given subtree, which can lead to significant performance gains since multisampling is not applied to other parts of the scene.</p>
<p><b>Note: </b>Enabling multisampling can be potentially expensive regardless of the layer's size, as it incurs a hardware and driver dependent performance and memory cost.</p><p><b>Note: </b>This property is only functional when support for multisample renderbuffers and framebuffer blits is available. Otherwise the value is silently ignored.</p><p>This property was introduced in  Qt 5.10.</p>
</div></div><!-- @@@samples -->
<br/>
<!-- $$$sourceItem -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="sourceItem-prop">
<td class="tblQmlPropNode"><p>
<a name="sourceItem-prop"></a><span class="name">sourceItem</span> : <span class="type"><a href="qml-qtquick-item.html">Item</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the item to be rendered into the texture. Setting this to null while <a href="qml-qtquick-shadereffectsource.html#live-prop">live</a> is true, will release the texture resources.</p>
</div></div><!-- @@@sourceItem -->
<br/>
<!-- $$$sourceRect -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="sourceRect-prop">
<td class="tblQmlPropNode"><p>
<a name="sourceRect-prop"></a><span class="name">sourceRect</span> : <span class="type"><a href="../qtqml/qml-rect.html">rect</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property defines which rectangular area of the <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> to render into the texture. The source rectangle can be larger than <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> itself. If the rectangle is null, which is the default, the whole <a href="qml-qtquick-shadereffectsource.html#sourceItem-prop">sourceItem</a> is rendered to texture.</p>
</div></div><!-- @@@sourceRect -->
<br/>
<!-- $$$textureMirroring -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="textureMirroring-prop">
<td class="tblQmlPropNode"><p>
<a name="textureMirroring-prop"></a><span class="name">textureMirroring</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property defines how the generated OpenGL texture should be mirrored. The default value is <code>ShaderEffectSource.MirrorVertically</code>. Custom mirroring can be useful if the generated texture is directly accessed by custom shaders, such as those specified by <a href="qml-qtquick-shadereffect.html">ShaderEffect</a>. Mirroring has no effect on the UI representation of the <a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a> item itself.</p>
<ul>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.NoMirroring - No mirroring</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.MirrorHorizontally - The generated texture is flipped along X-axis.</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.MirrorVertically - The generated texture is flipped along Y-axis.</li>
</ul>
<p>This property was introduced in  Qt 5.6.</p>
</div></div><!-- @@@textureMirroring -->
<br/>
<!-- $$$textureSize -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="textureSize-prop">
<td class="tblQmlPropNode"><p>
<a name="textureSize-prop"></a><span class="name">textureSize</span> : <span class="type"><a href="../qtqml/qml-size.html">size</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the requested size of the texture. If it is empty, which is the default, the size of the source rectangle is used.</p>
<p><b>Note: </b>Some platforms have a limit on how small framebuffer objects can be, which means the actual texture size might be larger than the requested size.</p></div></div><!-- @@@textureSize -->
<br/>
<!-- $$$wrapMode -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="wrapMode-prop">
<td class="tblQmlPropNode"><p>
<a name="wrapMode-prop"></a><span class="name">wrapMode</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property defines the OpenGL wrap modes associated with the texture. Modifying this property makes most sense when the item is used as a source texture of a <a href="qml-qtquick-shadereffect.html">ShaderEffect</a>.</p>
<p>The default value is <code>ShaderEffectSource.ClampToEdge</code>.</p>
<ul>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.ClampToEdge - GL_CLAMP_TO_EDGE both horizontally and vertically</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.RepeatHorizontally - GL_REPEAT horizontally, GL_CLAMP_TO_EDGE vertically</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.RepeatVertically - GL_CLAMP_TO_EDGE horizontally, GL_REPEAT vertically</li>
<li><a href="qml-qtquick-shadereffectsource.html">ShaderEffectSource</a>.Repeat - GL_REPEAT both horizontally and vertically</li>
</ul>
<p><b>Note: </b>Some OpenGL ES 2 implementations do not support the GL_REPEAT wrap mode with non-power-of-two textures.</p></div></div><!-- @@@wrapMode -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$scheduleUpdate -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="scheduleUpdate-method">
<td class="tblQmlFuncNode"><p>
<a name="scheduleUpdate-method"></a><span class="name">scheduleUpdate</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Schedules a re-rendering of the texture for the next frame. Use this to update the texture when <a href="qml-qtquick-shadereffectsource.html#live-prop">live</a> is false.</p>
</div></div><!-- @@@scheduleUpdate -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
